Skip to content

fix(reconcile): notify ownKeys subscribers on pure keyed trailing removal#2795

Open
tsushanth wants to merge 1 commit into
solidjs:nextfrom
tsushanth:fix/reconcile-trailing-removal-notify
Open

fix(reconcile): notify ownKeys subscribers on pure keyed trailing removal#2795
tsushanth wants to merge 1 commit into
solidjs:nextfrom
tsushanth:fix/reconcile-trailing-removal-notify

Conversation

@tsushanth

Copy link
Copy Markdown

When keyed reconcile removes only trailing items from an array (for example [{id:1},{id:2},{id:3}] shrinks to [{id:1},{id:2}]), the common-prefix loop advances start past all matching items, which causes start > newEnd to be true and the early-exit branch to execute

Inside that branch, the two inner loops only run when there are new or updated items to write — there are none in a pure removal — so changed stays false, notifySelf(target) is skipped, and any memo that subscribed to the array's ownKeys via $TRACK is never invalidated

The length signal fires correctly, but that is a separate signal; ownKeys subscribers (which createSelector, spread patterns, and anything using $TRACK depend on) are silently stale

The same path exists in both applyStateFast and applyStateSlow

Fix: widen the notifySelf guard to also fire when the array length changed, regardless of whether any element was rewritten in this pass

Fixes #2773

…oval

When keyed reconcile removes only trailing items, the early-exit branch
skipped notifySelf because no element was rewritten (changed stayed false).
Widen the guard to also fire when the array length changed, ensuring
$TRACK subscribers are invalidated in both applyStateFast and applyStateSlow.

Fixes solidjs#2773
@changeset-bot

changeset-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 54b2175

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@solidjs/signals Patch
test-integration Patch
solid-js Patch
babel-preset-solid Patch
@solidjs/web Patch
@solidjs/html Patch
@solidjs/h Patch
@solidjs/universal Patch
@solidjs/element Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codspeed-hq

codspeed-hq Bot commented Jun 25, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 118 untouched benchmarks


Comparing tsushanth:fix/reconcile-trailing-removal-notify (54b2175) with next (a4ca10b)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant